package leetcode.editor.cn;

import java.util.HashSet;
import java.util.Set;

public class P357CountNumbersWithUniqueDigits {
    public static void main(String[] args) {
        Solution solution = new P357CountNumbersWithUniqueDigits().new Solution();
        System.out.println(solution.countNumbersWithUniqueDigits(2));

    }

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public int countNumbersWithUniqueDigits(int n) {
            int end = (int) Math.pow(10, n);
            int start = 0;
            int count = 0;
            while (start < end) {
                if (!hasDup(start)) {
                    count++;
                }
                start++;
            }
            return count;
        }

        public boolean hasDup(int n) {
            Set<Integer> set = new HashSet<>();
            while (n != 0) {
                int i = n % 10;
                if (set.contains(i)) {
                    return true;
                }else{
                    set.add(i);
                }
                n = n / 10;
            }
            return false;
        }
    }
//leetcode submit region end(Prohibit modification and deletion)

}